<!doctype html>
<html xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <title>首页</title>
    <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../../css/bootstrap.min.css">
    <link rel="stylesheet" href="../../css/bootstrapValidator.css">
    <script src="../../js/jquery-2.0.3.min.js"></script>
    <script src="../../js/bootstrap.min.js"></script>
    <script src="../../js/bootstrapValidator.js"></script>
    <script src="../../js/jquery.cookie.js"></script>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script src="../../js/hostConfig.js"></script>
    <script>
        var path = host_tomcatR;
    </script>
</head>
<body>
<div class="container" id="app">
    <div class="jumbotron">
        <h1>首页</h1>
        <p></p>
    </div>

    <h1>导航</h1>
    <div class="row">
        <div class="col-sm-4">
            <h3>信息</h3>
            <p>
                <a href="javascript:;">首页</a>
            </p>
        </div>
        <div class="col-sm-4">
            <div>
                <h3>后台权限管理</h3>
                <p v-if="msg.code=='0000'"><a href="/pages/manage/user/list.html">用户列表</a></p>
                <p v-if="permission.code=='0000'"><a href="/pages/manage/permission/list.html">权限列表</a></p>
                <p v-if="role.code=='0000'"><a href="/pages/manage/role/list.html">角色列表</a></p>
                <p v-if="role.code=='0000'"><a href="/pages/manage/userrole/list.html">用户角色列表</a></p>
            </div>
        </div>
        <div class="col-sm-4">
            <h3>个人</h3>
            <p><a href="/register/">注册</a></p>
            <p><a href="/pages/reglog/login.html" >登录</a></p>
            <p><a href="javascript:;" id="log_out" v-on:click="submitUserInfo">注销</a></p>
        </div>
    </div>
</div>
</body>
</html>

<script type="text/javascript">
    axios({method: 'post', url: path + '/login/isAuthenticated', withCredentials: true}).then(response => {
        if (response.data.code != "0000") {
            window.location.href = "/pages/reglog/login.html";
        }
    });

    //    $.ajax({
    //        type: "post",
    //        url: path + "/login/isAuthenticated",
    //        dataType: "json",
    //        xhrFields: {
    //            withCredentials: true
    //        },
    //        crossDomain: true,
    //        success: function (data) {
    //            //如果未授权则跳转的登录界面
    //            if (data.code != "0000") {
    //                window.location.href = "/pages/reglog/login.html";
    //            }
    //        },
    //        error: function (xhr, type) {
    //            alert("error");
    //            console.log(xhr);
    //        }
    //    });


    var app = new Vue({
        el: '#app',
        data: {
            msg: {},
            permission: {},
            role: {},
            roleuser: {}
        },
        mounted() {
            axios({
                method: 'post',
                url: path + '/p/hasUserQuery',
                withCredentials: true
            }).then(response => this.msg = response.data);
            axios({
                method: 'post',
                url: path + '/p/hasPermissionsQuery',
                withCredentials: true
            }).then(response => this.permission = response.data);
            axios({
                method: 'post',
                url: path + '/p/hasRoleQuery',
                withCredentials: true
            }).then(response => this.role = response.data);
            axios({
                method: 'post',
                url: path + '/p/hasUserRoleQuery',
                withCredentials: true
            }).then(response => this.roleuser = response.data);
        },
        methods: {
            submitUserInfo: function () {
                axios({method: 'post', url: path + '/logout', withCredentials: true}).then(res => {
//                    console.log(res.data);
                    if (res.data.code == "logout") {
                        window.location.href = "/pages/reglog/login.html";
                    }
                });
            }
        }
    });

</script>


<script></script>